import Vue from 'vue'
// 路由控制
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [{
  path: '/',
  name: 'login',
  meta: {
    title: '登录'
  },
  component: () => import('../views/Login')
},
// 登录
{
  path: '/login',
  name: 'login',
  meta: {
    title: '登录'
  },
  component: () => import('../views/Login')
},
// 首页
{
  path: '/Index',
  name: 'index',
  meta: {
    title: '首页'
  },
  component: () => import('../views/Index')
},
// 二手闲置
{
  path: '/catalog',
  name: 'catalog',
  meta: {
    title: '二手闲置'
  },
  component: () => import('../views/Catalog')
},
// 失物招领
{
  path: '/news',
  name: 'news',
  meta: {
    title: '失物招领'
  },
  component: () => import('../views/News')
},
// 资源共享
{
  path: '/faq',
  name: 'faq',
  meta: {
    title: '资源共享'
  },
  component: () => import('../views/Faq')
},
// 更多
{
  path: '/more',
  name: 'more',
  meta: {
    title: '更多'
  },
  component: () => import('../views/More'),
  children: [{
    path: '/checkout',
    name: 'checkout',
    meta: {
      title: '购物车'
    },
    component: () => import('../views/Checkout'),
  },
  {
    path: '/favorites',
    name: 'favorites',
    meta: {
      title: '我的发布'
    },
    component: () => import('../views/Favorites'),
  },
  // 个人中心
  {
    path: '/profile',
    name: 'profile',
    meta: {
      title: '个人中心'
    },
    component: () => import('../views/Profile'),
    children: [{
      path: '/profile',
      redirect: '/profile/myOrder',
      meta: {
        title: '我的订单',

      },
      component: () => import('../views/Profile/MyOrder')
    },
    {
      path: '/profile/myOrder',
      name: 'myOrder',
      meta: {
        title: '我的订单',

      },
      component: () => import('../views/Profile/MyOrder')
    },
    {
      path: '/profile/myInfo',
      name: 'myInfo',
      meta: {
        title: '个人信息',

      },
      component: () => import('../views/Profile/MyInfo')
    },
    {
      path: '/profile/changepsw',
      name: 'changepsw',
      meta: {
        title: '修改密码',

      },
      component: () => import('../views/Profile/ChangePsw')
    },
    {
      path: '/profile/changeEmail',
      name: 'changeemail',
      meta: {
        title: '邮箱换绑',

      },
      component: () => import('../views/Profile/ChangeEmail')
    },
    {
      path: '/profile/loginRecord',
      name: 'loginRecord',
      meta: {
        title: '登录记录',

      },
      component: () => import('../views/Profile/LoginRecord')
    },
    {
      path: '/profile/browseRecord',
      name: 'browseRecord',
      meta: {
        title: '实名认证',
      },
      component: () => import('../views/Profile/BrowseRecord')
    }

    ]
  },
  {
    path: '/privacy',
    name: 'privacy',
    meta: {
      title: '隐私协议'
    },
    component: () => import('../views/Privacy'),
  },
  {
    path: '/contacts',
    name: 'contacts',
    meta: {
      title: '联系我们'
    },
    component: () => import('../views/Contacts'),
  },
  {
    path: '/forgetpsw',
    name: 'forgetpsw',
    meta: {
      title: '资源详情'
    },
    component: () => import('../views/Forgetpsw'),
  },
  {
    path: '/aboutus',
    name: 'aboutus',
    meta: {
      title: '关于我们'
    },
    component: () => import('../views/Aboutus'),
  }
  ]
},
{
  path: '/details',
  name: 'details',
  meta: {
    title: '详情展示'
  },
  component: () => import('../views/Details')
},
{
  path: '/lostDetails',
  name: 'lostDetails',
  meta: {
    title: '失物详情'
  },
  component: () => import('../views/LostDetails')
},
{
  path: '/message',
  name: 'message',
  meta: {
    title: '失物详情'
  },
  component: () => import('../views/Message')
}
]



const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export default router